package xyz.talentboy.service.serviceImpl;

import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import xyz.talentboy.TL.bean.TuRingRes;
import xyz.talentboy.TL.util.TuRingUtil;
import xyz.talentboy.common.constant.MessageType;
import xyz.talentboy.model.MessageResponse;
import xyz.talentboy.service.ICoreMessageService;

@Service
public class CoreMessageService implements ICoreMessageService {

	private static final Logger logger = LoggerFactory.getLogger(CoreMessageService.class);

	@Autowired
	private TuRingUtil tuRingUtil;

	@Override
	public String dispatcherMessage(Map<String, String> map) {
		String responseStr = "";
		MessageType messageType = Enum.valueOf(MessageType.class, map.get("MsgType"));
		switch (messageType) {
		case text:
			logger.info("text消息请求");
			break;
		case link:
			break;
		case voice:
			break;
		case video:
			break;
		case shortvideo:
			break;
		case image:
			break;
		case location:
			break;
		default:
			break;
		}
		responseStr = buildTuRingStr(map);
		return MessageResponse.getMessage(map.get("FromUserName"), map.get("ToUserName"), responseStr);
	}

	/**
	 * 
	 * @param trRingRes
	 * @return
	 */
	private String buildTuRingStr(Map<String, String> map) {
		TuRingRes trRingRes = new TuRingRes();
		trRingRes = tuRingUtil.postTL(map.get("Content"), map.get("FromUserName"));
		return trRingRes.getText();
	}

}
